package com.arsn.myf.system.service.impl;

import com.arsn.myf.common.util.StringUtils;
import com.arsn.myf.system.entity.Dict;
import com.arsn.myf.system.mapper.DictMapper;
import com.arsn.myf.system.service.DictService;
import com.arsn.myf.system.vo.DictVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 字典实现层
 * @author zhongrj
 */
@Service
public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements DictService {

    /**
     * 自定义查询字典分页数据
     * @param page
     * @param dict
     * @return
     */
    @Override
    public IPage<DictVO> selectPageDictList(Page<DictVO> page, DictVO dict) {
        return page.setRecords(baseMapper.selectPageDictList(page,dict));
    }

    /**
     * 字典列表
     * @param dict 字典参数实体
     * @return
     */
    @Override
    public List<DictVO> getDictList(DictVO dict) {
        //判断查询参数
        if (StringUtils.isBlank(dict.getDictName()) && null==dict.getParentId()) {
            dict.setParentId(0L);
        }
        return baseMapper.getDictList(dict);
    }

    /**
     * 根据字典编号查询字典
     * @param dict
     * @return
     */
    @Override
    public List<DictVO> getDictListByCode(DictVO dict) {
        return baseMapper.getDictListByCode(dict);
    }
}
